#include "disk_partition_base.h"

CDiskPartBase::CDiskPartBase()
{
	m_pDisk = NULL;
	m_isGPT = false;
	m_max_part = 4;
}

CDiskPartBase::~CDiskPartBase()
{
}

int CDiskPartBase::Init(CDiskBlk * disk_blk)
{
	m_pDisk = disk_blk;

    return 0;
}

int CDiskPartBase::AddPart(PART_INFO_S  part)
{
	if (m_pDisk == NULL)
	{
		return -1;
	}
	uint64_t capacity = m_pDisk->get_capacity();
	int part_num = 0;
	if(part.start > capacity )
	{
		fprintf(stderr,"over disk stat %lld capacity %lld,\n", part.start,capacity);
		return -2;
	}

	if (part.start + part.len > capacity)
	{
		fprintf(stderr, "over disk stat %lld  len %lld capacity %lld,\n",
			part.start, part.len, capacity);
		return -2;
	}

	m_vec_part.push_back(part);
	part_num = m_vec_part.size();

	fprintf(stderr, "AddPart ok size %d.\n", part_num);
	return part_num;
}

int CDiskPartBase::AnalysePartTable()
{
	return 0;
}